<template>
  <div class="me">
    <div class="header">
      我的
    
    </div>
    <div class="user">
      <div class="info">
        <a-avatar :size="95" icon="user" :src="userInfo.avatar" />
        <div class="name">
          <b>{{ userInfo.name }}</b>
        </div>
        <a-icon
          class="icon"
          type="right"
          @click="$router.push({ name: 'Edit' })"
        />
      </div>
    </div>
    <div class="service">
      <div class="commonly-service">
       
        <service class="comm"
          v-for="(item, index) in datas"
          :key="index"
          :serviceInfo="item"
        ></service>
      </div>
    </div>
    <a-button class="btn" block shape="round"  @click="loginOut()">退出登录</a-button>
  </div>
</template>

<script>
import Service from "../components/Service.vue";
import addressUrl from "../assets/imgs/service/zwadd.png";
// import buyUrl from "../assets/imgs/service/o1.jpg";
import clausepolicyUrl from "../assets/imgs/service/pant.png";
import customerServiceUrl from "../assets/imgs/service/call.png";

export default {
  components: { Service },
  computed: {
    userInfo() {
      return this.$store.getters.userInfo;
    },
  },
  data() {
    return {
      datas: [
        {
          imgUrl: addressUrl,
          name: "我的地址",
          path: "Address",
        },
        // {
        //   imgUrl: buyUrl,
        //   name: "我常买",
        //   path: "",
        // },
        {
          imgUrl: customerServiceUrl,
          name: "联系客服",
          path: "CustomerService",
        },
        {
          imgUrl: clausepolicyUrl,
          name: "条款政策",
          path: "ClausePolicy",
        },
      ],
    };
  },
  methods: {
    //调用store中的LOGOUT方法，直接清空store中存储对象，再跳转到首页
    loginOut() {
      this.$store.commit("LOGOUT");
      this.$router.push({ name: "Login" });
      // this.$router.go()
    },
  },
};
</script>

<style lang="scss" scoped>
.me {
  width: 100%;
  height: 100%;
  background-color: white;
  .header {
    width: 100%;
    text-align: center;
    color: white;
    background-color:#4CD96F;
    font-size: 18px;
    .login {
      display: inline-block;
      float: right;
      font-size: 10px;
      margin-top: 10px;
    }
  }
  .user {
    height: 100px;
    background-color: #4CD96F;
    color: #fff;
    display: flex;
    margin-top: 2px;
    .info {
      padding: 10px;
      width: 100%;
      display: flex;
      align-items: center;
      color:French grey;
      .name {
        width: 40%;
        padding: 8px;
        font-size:15px;
      }
      .icon {
        position: relative;
        right: -100px;
        font-size: 20px;
        color: white;
      }
    }
  }
  .service {

    margin-top: 0px;
  }
  .p {
    font-size:8px;
  }
  b {
    font-size:15px;
    color:white;
  }
.comm{
  height:52px;
  border:1px French grey solid;
  
 
}
.service-name{
  font-size: 10px;
}

  .btn {
    display: block;
    margin:0 auto;
  
    background-color: #4CD96F;
    margin-top:147px;
  }
}
</style>